const deepClone = require("../template.js")

/** 5. 边界情况测试 */
function testEdge() {
  console.log(
    "5.1 原型链处理:",
    (() => {
      function Person(name) {
        this.name = name
      }
      Person.prototype.greet = function () {
        return "Hello " + this.name
      }
      const person = new Person("Alice")
      const cloned = deepClone(person)
      return cloned.name === "Alice" && cloned !== person
    })()
  )

  console.log(
    "5.2 复杂混合场景:",
    (() => {
      const complex = {
        date: new Date("2023-01-01"),
        arr: [1, { nested: true }],
        map: new Map([["key", "value"]]),
        regex: /test/g,
        fn: () => "function"
      }
      const cloned = deepClone(complex)
      return (
        cloned !== complex &&
        cloned.date instanceof Date &&
        cloned.arr !== complex.arr &&
        cloned.map instanceof Map
      )
    })()
  )

  console.log("--------------------")
}

testEdge()

module.exports = testEdge
